import { shallowRef } from "vue";
import { getChartList } from "@/api/datalist";

interface ChartType {
  date: string[];
  fields: string[];
  [key: string]: string[];
}

export const useChart = () => {
  const chartData = shallowRef<ChartType>();

  const getChartData = (code: string) => {
    if (code) {
      getChartList<ChartType>({
        code
      }).then(res => {
        chartData.value = res.data;
      });
    }
  };

  const handleClick = (tab, event) => {
    console.log(tab, event);
  };
  return {
    chartData,
    getChartData,
    handleClick
  };
};
